const fs = require('fs');

//封装一个函数
function myReadfile (filename) {
     let p = new Promise((resolve, reject) => {
        fs.readFile(filename, 'utf-8', (err, data) => {
            err ? reject(err) : resolve(data.length);
        })
    });
    return p;
}

//获取结果
myReadfile('./files/a.txt').then(result => {
    console.log(result);
    return myReadfile('./files/b.txt');
}).then(result => {
    console.log(result);
   return myReadfile('./files/c.txt');
}).then(result => {
    console.log(result);
}).catch(err => {
    console.log(err);
})